<template>
  <el-dialog
    v-model="props.show"
    style="padding: 0 !important"
    :show-close="false"
    :width="props.width"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :before-close="handelbeforeClose"
  >
    <div class="header">
      <span>{{ props.title }}</span>
      <el-icon size="20" @click="handelbeforeClose"><CloseBold /></el-icon>
    </div>
    <div class="content">
      <slot></slot>
    </div>
    <template #footer v-if="props.isShowSubmit">
      <div class="dialog-footer" :class="{ shadow: isShadow }" :style="{ justifyContent: props.btnPosition }">
        <div class="left">
          <slot name="footLeft"></slot>
        </div>
        <div class="right">
          <el-button @click="handelbeforeClose" v-if="props.isShowBtn">取消</el-button>
          <el-button type="primary" @click="handelClickSubmit">{{ props.submitText }} </el-button>
        </div>
      </div>
    </template>
    <div v-if="!props.isShowSubmit" style="height: 20px"></div>
  </el-dialog>
</template>
<script setup>
import { defineProps, defineEmits } from "vue";
const props = defineProps({
  show: {
    type: Boolean,
    default: false
  },
  width: {
    type: String,
    default: "500px"
  },
  title: {
    type: String,
    default: "----"
  },
  btnPosition: {
    type: String,
    default: "right"
  },
  submitText: {
    type: String,
    default: "保存"
  },
  isShowBtn: {
    type: Boolean,
    default: true
  },
  isShadow: {
    type: Boolean,
    default: true
  },
  isShowSubmit: {
    type: Boolean,
    default: true
  }
});
const emits = defineEmits(["close", "save"]);
const handelbeforeClose = () => {
  emits("close");
};
const handelClickSubmit = () => {
  emits("save");
  // 提交数据
};
</script>
<style scoped lang="scss">
:deep(.el-dialog) {
  padding: 0 !important;
}
.content {
  height: 100%;
  padding: 0 20px;
}
.header {
  display: flex;
  justify-content: space-between;
  height: 50px;
  align-items: center;
  padding: 0 20px;
  span {
    font-size: 16px;
    position: relative;
    margin-left: 10px;
  }
  i {
    cursor: pointer;
  }
  span::before {
    content: " ";
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #409eff;
    margin-right: 10pxrgb (47, 53, 225);
  }
}
.dialog-footer {
  &.shadow {
    box-shadow: 0px -3px 10px 0px rgba(4, 24, 48, 0.1);
  }
  background: #ffffff;
  height: 64px;

  border-radius: 0px 0px 0px 0px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 20px;
  border-radius: 10px;
  .left {
    display: flex;
    align-items: center;
  }
  button {
    width: 120px;
    height: 36px;
  }
}
</style>
